package com.dd.test.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * @author: lkd
 * @date: 2023/04/23/15:43
 * @Description: 自定义listener，需要实现ServletContextListener接口
 * <p> tomcat启动会遍历所有配置的listener，对于实现了ServletContextListener接口的会调用contextInitialized方法
 */
public class MyTestListener implements ServletContextListener {

	@Override
	public void contextInitialized(ServletContextEvent sce) {
		System.out.println("容器初始化");
		System.out.println(sce);
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		System.out.println("容器关闭");
	}
}
